demos: Add devel styling
authorMatthias Clasen <mclasen@redhat.com>
Fri, 12 Feb 2021 04:35:26 +0000 (23:35 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 12 Feb 2021 05:08:55 +0000 (00:08 -0500)
Add a -Dprofile=devel meson option, and add some visual
hints to the demos that you are running a nightly build.

12 files changed:
demos/gtk-demo/main.c
demos/gtk-demo/meson.build
demos/icon-browser/iconbrowserapp.c
demos/icon-browser/meson.build
demos/meson.build
demos/node-editor/meson.build
demos/node-editor/node-editor-application.c
demos/print-editor/meson.build
demos/print-editor/print-editor.c
demos/widget-factory/meson.build
demos/widget-factory/widget-factory.c
meson_options.txt

index bb1de0d6e902a9a762479f4aaa2c97396b5e0cb5..5ae00882ac70db8ad8c1db3742b79f00993cd7a4 100644 (file)
@@ -25,6 +25,8 @@
 #include "demos.h"
 #include "fontify.h"
 
+#include "demo_conf.h"
+
 static GtkWidget *info_view;
 static GtkWidget *source_view;
 
@@ -196,16 +198,20 @@ activate_about (GSimpleAction *action,
                           gtk_get_micro_version ());
   g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
 
-  version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
+  version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
                              PACKAGE_VERSION,
+                             g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
+                             g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
                              gtk_get_major_version (),
                              gtk_get_minor_version (),
                              gtk_get_micro_version ());
 
   gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
-                         "program-name", "GTK Demo",
+                         "program-name", g_strcmp0 (PROFILE, "devel") == 0
+                                         ? "GTK Demo (Development)"
+                                         : "GTK Demo",
                          "version", version,
-                         "copyright", "© 1997—2020 The GTK Team",
+                         "copyright", "© 1997—2021 The GTK Team",
                          "license-type", GTK_LICENSE_LGPL_2_1,
                          "website", "http://www.gtk.org",
                          "comments", "Program to demonstrate GTK widgets",
@@ -901,6 +907,9 @@ activate (GApplication *app)
   window = (GtkWidget *)gtk_builder_get_object (builder, "window");
   gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (window));
 
+  if (g_strcmp0 (PROFILE, "devel") == 0)
+    gtk_widget_add_css_class (window, "devel");
+
   action = g_simple_action_new ("run", NULL);
   g_signal_connect (action, "activate", G_CALLBACK (activate_run), window);
   g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (action));
index 546d76d2f7bdfc01ca4d75c6ecea2ae172ab1325..f2deff1c3707a60ffe84c5e93fc4a5ae7a282962 100644 (file)
@@ -167,6 +167,8 @@ foreach flag: common_cflags
   endif
 endforeach
 
+gtkdemo_deps += [ demo_conf_h ]
+
 executable('gtk4-demo',
   sources: [demos, demos_h, extra_demo_sources, gtkdemo_resources],
   c_args: gtkdemo_args + demo_cflags,
index ee55407de48acb891a12701b5ba809824abc532d..3f08c8c36a5fa384fa09ab866da849fdcbacbe3f 100644 (file)
@@ -4,6 +4,8 @@
 #include "iconbrowserapp.h"
 #include "iconbrowserwin.h"
 
+#include "demo_conf.h"
+
 struct _IconBrowserApp
 {
   GtkApplication parent;
@@ -75,16 +77,20 @@ about_activated (GSimpleAction *action,
                           gtk_get_minor_version (),
                           gtk_get_micro_version ());
   g_string_append_printf (s, "\nIcon theme\n\t%s", icon_theme);
-  version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
+  version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
                              PACKAGE_VERSION,
+                             g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
+                             g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
                              gtk_get_major_version (),
                              gtk_get_minor_version (),
                              gtk_get_micro_version ());
 
   gtk_show_about_dialog (GTK_WINDOW (gtk_application_get_active_window (app)),
-                         "program-name", "GTK Icon Browser",
+                         "program-name", g_strcmp0 (PROFILE, "devel") == 0
+                                         ? "GTK Icon Browser (Development)"
+                                         : "GTK Icon Browser",
                          "version", version,
-                         "copyright", "© 1997—2020 The GTK Team",
+                         "copyright", "© 1997—2021 The GTK Team",
                          "license-type", GTK_LICENSE_LGPL_2_1,
                          "website", "http://www.gtk.org",
                          "comments", "Program to browse themed icons",
@@ -129,6 +135,10 @@ icon_browser_app_activate (GApplication *app)
   IconBrowserWindow *win;
 
   win = icon_browser_window_new (ICON_BROWSER_APP (app));
+
+  if (g_strcmp0 (PROFILE, "devel") == 0)
+    gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
+
   gtk_window_present (GTK_WINDOW (win));
 }
 
index f0a449ceeb061884c54a023d98281f9d56c10314..3922811f927c457ee9e2213b14dadd1d1d959e6e 100644 (file)
@@ -14,7 +14,7 @@ iconbrowser_resources = gnome.compile_resources('iconbrowser_resources',
 executable('gtk4-icon-browser',
   sources: [iconbrowser_sources, iconbrowser_resources],
   c_args: common_cflags,
-  dependencies: libgtk_dep,
+  dependencies: [ libgtk_dep, demo_conf_h ],
   include_directories: confinc,
   gui_app: true,
   link_args: extra_demo_ldflags,
index 42590368a23f2a6e014bd1fffc8757f5395f281e..79c530f4b761d8f131f206eb5b47f61129e8eb7d 100644 (file)
@@ -1,3 +1,19 @@
+demo_conf = configuration_data()
+demo_conf.set_quoted('PROFILE', get_option('profile'))
+demo_conf.set_quoted('VCS_TAG', '@VCS_TAG@')
+
+demo_conf_h = declare_dependency(
+  sources: vcs_tag(
+             command: [ 'git', 'rev-parse', '--short', 'HEAD' ],
+             fallback: get_option('profile') != 'default' ? 'devel' : '',
+             input: configure_file(
+                      output: 'demo_conf.h.in',
+                      configuration: demo_conf
+                    ),
+             output: 'demo_conf.h'
+           )
+)
+
 subdir('constraint-editor')
 subdir('gtk-demo')
 subdir('icon-browser')
index 336301171baefff4bd160b91bb43981e88dfd843..932ec19b1c288e2da343800ef04f91aa0821fc32 100644 (file)
@@ -12,7 +12,7 @@ node_editor_resources = gnome.compile_resources('node_editor_resources',
 
 executable('gtk4-node-editor',
   sources: [node_editor_sources, node_editor_resources],
-  dependencies: libgtk_dep,
+  dependencies: [ libgtk_dep, demo_conf_h ],
   include_directories: confinc,
   c_args: [
     '-DNODE_EDITOR_SOURCE_DIR="@0@/../../testsuite/gsk/compare/"'.format(meson.current_source_dir())
index d9a5ce34ded3fceee952f7efe871caae9aa1feb2..22aa7433916f36edc9c753a0fac6625805539ed6 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "node-editor-window.h"
 
+#include "demo_conf.h"
+
 static const char *css =
 "textview.editor {"
 "  color: rgb(192, 197, 206);"
@@ -94,17 +96,21 @@ activate_about (GSimpleAction *action,
 
   g_string_append_printf (s, "\nRenderer\n\t%s", renderer);
 
-  version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
+  version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
                              PACKAGE_VERSION,
+                             g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
+                             g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
                              gtk_get_major_version (),
                              gtk_get_minor_version (),
                              gtk_get_micro_version ());
 
   dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
                          "transient-for", gtk_application_get_active_window (app),
-                         "program-name", "GTK Node Editor",
+                         "program-name", g_strcmp0 (PROFILE, "devel") == 0
+                                         ? "GTK Node Editor (Development)"
+                                         : "GTK Node Editor",
                          "version", version,
-                         "copyright", "© 2019—2020 The GTK Team",
+                         "copyright", "© 2019—2021 The GTK Team",
                          "license-type", GTK_LICENSE_LGPL_2_1,
                          "website", "http://www.gtk.org",
                          "comments", "Program to test GTK rendering",
@@ -207,6 +213,10 @@ node_editor_application_activate (GApplication *app)
   NodeEditorWindow *win;
 
   win = node_editor_window_new (NODE_EDITOR_APPLICATION (app));
+
+  if (g_strcmp0 (PROFILE, "devel") == 0)
+    gtk_widget_add_css_class (GTK_WIDGET (win), "devel");
+
   gtk_window_present (GTK_WINDOW (win));
 }
 
index 4be4a6f4a6ae826c9bd9fca3b23b727e929b7db1..e0dbf773d9c00cc7127d122de32b6a77ff12161f 100644 (file)
@@ -1,7 +1,7 @@
 executable('gtk4-print-editor',
   sources: ['print-editor.c'],
   c_args: common_cflags,
-  dependencies: libgtk_dep,
+  dependencies: [ libgtk_dep, demo_conf_h ],
   include_directories: confinc,
   gui_app: true,
   link_args: extra_demo_ldflags,
index 81dce416926193e63d3c9bf328b002484a3a8c06..2ac806df2f89cf9a6f0cbace111ac4f00b62b819 100644 (file)
@@ -4,6 +4,8 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include "demo_conf.h"
+
 static GtkWidget *main_window;
 static GFile *filename = NULL;
 static GtkPageSetup *page_setup = NULL;
@@ -641,17 +643,21 @@ activate_about (GSimpleAction *action,
   g_strfreev (backends);
   g_free (setting);
 
-  version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
+  version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
                              PACKAGE_VERSION,
+                             g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
+                             g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
                              gtk_get_major_version (),
                              gtk_get_minor_version (),
                              gtk_get_micro_version ());
 
   dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
                          "transient-for", main_window,
-                         "program-name", "GTK Print Editor",
+                         "program-name", g_strcmp0 (PROFILE, "devel") == 0
+                                         ? "GTK Print Editor (Development)"
+                                         : "GTK Print Editor",
                          "version", version,
-                         "copyright", "© 2006-2020 Red Hat, Inc",
+                         "copyright", "© 2006-2021 Red Hat, Inc",
                          "license-type", GTK_LICENSE_LGPL_2_1,
                          "website", "http://www.gtk.org",
                          "comments", "Program to demonstrate GTK printing",
@@ -807,6 +813,10 @@ activate (GApplication *app)
   GtkWidget *contents;
 
   main_window = gtk_application_window_new (GTK_APPLICATION (app));
+
+  if (g_strcmp0 (PROFILE, "devel") == 0)
+    gtk_widget_add_css_class (GTK_WIDGET (main_window), "devel");
+
   gtk_window_set_icon_name (GTK_WINDOW (main_window), "text-editor");
   gtk_window_set_default_size (GTK_WINDOW (main_window), 400, 600);
   gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (main_window), TRUE);
index e43cb72c8c8cc55820897690d3a496531ea85049..e248963e24238ab5b7c67534e0f0d05f88417388 100644 (file)
@@ -8,7 +8,7 @@ widgetfactory_resources = gnome.compile_resources('widgetfactory_resources',
 executable('gtk4-widget-factory',
   sources: ['widget-factory.c', widgetfactory_resources],
   c_args: common_cflags,
-  dependencies: libgtk_dep,
+  dependencies: [ libgtk_dep, demo_conf_h ],
   include_directories: confinc,
   gui_app: true,
   link_args: extra_demo_ldflags,
index 6d022bb2032b374e2965566a8dcf5fad9452ef1c..ef952aca6abd0f7ff9ce989b4157b4dab2218832 100644 (file)
@@ -25,6 +25,8 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include "demo_conf.h"
+
 static void
 change_dark_state (GSimpleAction *action,
                     GVariant      *state,
@@ -300,8 +302,10 @@ activate_about (GSimpleAction *action,
                           gtk_get_micro_version ());
   g_string_append_printf (s, "\nA link can appear here: <http://www.gtk.org>");
 
-  version = g_strdup_printf ("%s\nRunning against GTK %d.%d.%d",
+  version = g_strdup_printf ("%s%s%s\nRunning against GTK %d.%d.%d",
                              PACKAGE_VERSION,
+                             g_strcmp0 (PROFILE, "devel") == 0 ? "-" : "",
+                             g_strcmp0 (PROFILE, "devel") == 0 ? VCS_TAG : "",
                              gtk_get_major_version (),
                              gtk_get_minor_version (),
                              gtk_get_micro_version ());
@@ -309,9 +313,11 @@ activate_about (GSimpleAction *action,
   dialog = g_object_new (GTK_TYPE_ABOUT_DIALOG,
                          "transient-for", gtk_application_get_active_window (app),
                          "modal", TRUE,
-                         "program-name", "GTK Widget Factory",
+                         "program-name", g_strcmp0 (PROFILE, "devel") == 0
+                                         ? "GTK Widget Factory (Development)"
+                                         : "GTK Widget Factory",
                          "version", version,
-                         "copyright", "© 1997—2020 The GTK Team",
+                         "copyright", "© 1997—2021 The GTK Team",
                          "license-type", GTK_LICENSE_LGPL_2_1,
                          "website", "http://www.gtk.org",
                          "comments", "Program to demonstrate GTK themes and widgets",
@@ -2065,6 +2071,10 @@ activate (GApplication *app)
     }
 
   window = (GtkWindow *)gtk_builder_get_object (builder, "window");
+
+  if (g_strcmp0 (PROFILE, "devel") == 0)
+    gtk_widget_add_css_class (GTK_WIDGET (window), "devel");
+
   gtk_application_add_window (GTK_APPLICATION (app), window);
   g_action_map_add_action_entries (G_ACTION_MAP (window),
                                    win_entries, G_N_ELEMENTS (win_entries),
index 71b01ec5c83c97011ea1421a91aadf0b1b734282..16a1cbd9fed82edd3609dfe14cb871420f140c41 100644 (file)
@@ -111,6 +111,12 @@ option('demos',
        value: 'true',
        description : 'Build demo programs')
 
+option('profile',
+       type: 'combo',
+       choices: [ 'default', 'devel' ],
+       value: 'default',
+       description : 'Profile to use for demos')
+
 option('build-examples',
        type: 'boolean',
        value: 'true',